Graphics processing systems

ABSTRACT

The present disclosure relates to a graphics processors and graphics processing systems. In the graphics processor, the rasterizer may operate to identify pairs of fragments for a primitive being rendered for which not all the sampling positions in the fragments are covered by the primitive. When the fragments reach the fragment shader, corresponding execution threads may be spawned for execution by the fragment shader to process the fragments. A first part of the fragment shader program that uses the helper threads of the thread groups may then be executed. There may then be a merge instruction in the fragment shader program which operates to cause the active threads of the thread groups to be merged into a single, combined thread group. Following this thread group merger, the remaining program steps of the fragment shader program may be executed for the merged thread group.

BACKGROUND

The technology described herein relates to graphics processors, and inparticular to the operation of graphics processors that include one ormore programmable processing stages (“shaders”).

Graphics processing is typically carried out in a pipelined fashion,with one or more pipeline stages operating on the data to generate thefinal render output, e.g. frame that is displayed. Many graphicsprocessing pipelines now include one or more programmable processingstages, commonly referred to as “shaders”. For example, a graphicsprocessing pipeline may include one or more of, and typically all of, ageometry shader, a vertex shader and a fragment (pixel) shader. Theseshaders are programmable processing stages that execute shader programson input data values to generate a desired set of output data (e.g.appropriately shaded and rendered fragment data in the case of afragment shader) for processing by the rest of the graphics pipelineand/or for output. The shaders of the graphics processing pipeline mayshare programmable processing circuitry, or they may each be distinctprogrammable processing units.

A graphics processing unit (GPU) shader core is thus a processing unitthat performs graphics processing by running small programs for eachgraphics item in a graphics output to be generated, such as a rendertarget, e.g. frame (an “item” in this regard is usually a vertex or asampling position (e.g. in the case of a fragment shader). Thisgenerally enables a high degree of parallelism, in that a typical renderoutput, e.g. frame, features a rather large number of vertices andfragments, each of which can be processed independently.

In graphics shader operation, each “item” will be processed by means ofan execution thread which will execute the shader program in questionfor the graphics “item” in question.

A known way to improve shader execution efficiency is to group executionthreads (where each thread corresponds, e.g., to one vertex or onesampling position) into “groups” or “bundles” of threads, where thethreads of one group are run in lockstep, one instruction at a time. Inthis way, it is possible to share instruction fetch and schedulingresources between all the threads in the group. (Other terms used forsuch thread groups include “warps” and “wavefronts”. For convenience theterm “thread group” will be used herein, but this is intended toencompass all equivalent terms and arrangements, unless otherwiseindicated.)

In the case of fragment shaders (shaders that are run once for eachsampling position in a primitive of a render output), a thread grouptypically contains one or more “quads”, where a “quad” is a 2×2 group ofsampling positions. Organising sampling positions into quads in thismanner is beneficial for some of the operations done in a fragmentshader, such as sampling point-delta calculations and operations thatdepend on such sampling point-deltas, such as texture lookups withmipmapping.

The Applicants have recognised that in such arrangements, at the edge ofa primitive, the 2×2 sampling position quad may straddle the edge of theprimitive, with some of the sampling positions being inside theprimitive and other sampling positions being outside. In this case,threads will still be started for all four sampling positions in thequad, but in effect only those sampling positions that are covered bythe primitive will be “active” threads.

However, some fragment shading processing is still required for thethreads that correspond to sampling positions that are outside theprimitive (which will be referred to herein as “inactive” and/or“helper” threads for convenience). This is because, for example, some ofthe fragment shading results for such inactive (“helper”) threads areneeded as inputs to some of the fragment shading operations, such assampling position-delta type calculations. (The results computed by suchhelper threads are then discarded at the end of the fragment shader (asthey are not otherwise required).)

FIG. 1 illustrates this situation.

FIG. 1 shows schematically an array 101 of sampling positions 102 of agraphics output to be generated, in which respective 2×2 groups ofsampling positions are organised into “quads” 103 that will be processedin common.

When a primitive is rasterised, the rasteriser will identify thosesampling position quads (groups) that are at least partially covered bythe primitive, and issue a graphics fragment for rendering for each atleast partially covered quad (group (set) of sampling positions). Eachsuch fragment will then be processed by the fragment shader as a threadgroup (warp), with each covered sampling position being an “active”thread in the group (warp) and any uncovered sampling positions beinginactive (“helper”) threads.

FIG. 1 shows an exemplary primitive 104 overlaying the array of samplingpositions. It can be seen from FIG. 1 that when the sampling positionquad 105 falls to be processed for the primitive 103, three of thesampling positions within the 2×2 quad 105 will be “active” (i.e.represent sampling positions within the primitive 3), but the fourthsampling position 106 in the quad 104 will be “inactive” as it fallsoutside the edge of the primitive 103. Thus, when the fragment shaderprogram is executed for the quad 104, the thread within the thread groupfor the uncovered sampling position 106 will be executed and treated asa “helper” thread.

The Applicants believe that there remains scope for improvements to thehandling of thread groups, particularly in shaders of graphicsprocessing pipelines.

BRIEF DESCRIPTION OF THE DRAWINGS

A number of embodiments of the technology described herein will now bedescribed by way of example only and with reference to the accompanyingdrawings, in which:

FIG. 1 shows schematically a primitive overlaying a grid of samplingpoints;

FIG. 2 shows an exemplary computer graphics processing system;

FIG. 3 shows schematically a graphics processing pipeline that can beoperated in the manner of the technology described herein;

FIG. 4 shows schematically the compiling of a shader program forexecution by a graphics processing pipeline;

FIG. 5 shows schematically a first embodiment of the technologydescribed herein;

FIGS. 6A and 6B show schematically the use of registers in the firstembodiment of the technology described herein;

FIG. 7 shows schematically the operation of the compiler in the firstembodiment of the technology described herein;

FIG. 8 shows schematically a second embodiment of the technologydescribed herein;

FIGS. 9A and 9B show schematically the use of registers in the secondembodiment of the technology described herein; and

FIG. 10 shows schematically the operation of the compiler in the secondembodiment of the technology described herein.

Like reference numerals are used for like components where appropriatein the drawings.

DETAILED DESCRIPTION

A first embodiment of the technology described herein comprises a methodof operating a graphics processing pipeline which includes aprogrammable shading stage that executes instructions to perform shadingoperations, in which execution threads may be grouped together intothread groups in which the threads of the group are executed inlockstep, one instruction at a time, the method comprising:

issuing to the shader stage a shader program for execution by the shaderstage to process execution threads for generating a render output,together with a thread group merge event indication that indicates apoint in the shader program execution where thread groups for which notall the threads in the thread group are active may be merged;

the graphics processing pipeline:

identifying a set of two or more thread groups to be processed by theshading stage for which not all the threads in the thread groups areactive and which may be merged into a single thread group; and

the shading stage:

-   -   executing the shader program for the identified thread groups,        the executing the shader program for the identified thread        groups including:        -   when the identified thread groups have reached the thread            group merge event indication, merging the thread groups into            a single thread group containing the active threads from            each of the thread groups; and        -   executing further instructions in the shader program after            the merge event indication point for the merged thread            group.

A second embodiment of the technology described herein comprises a dataprocessing system comprising:

a graphics processing pipeline that includes a programmable shadingstage that executes instructions to perform shading operations, and inwhich execution threads may be grouped together into thread groups inwhich the threads of the group are executed in lockstep, one instructionat a time, and

a compiler that compiles programs for the shading stage to generateinstructions for execution by the shading stage;

wherein the compiler is configured to:

issue to the shader stage a shader program for execution by the shaderstage to process execution threads for generating a render output,together with a thread group merge event indication that indicates apoint in the shader program execution where thread groups for which notall the threads in the thread group are active may be merged;

the graphics processing pipeline is configured to:

identify respective sets of two or more thread groups to be processed bythe shading stage for which not all the threads in the thread groups areactive and which may be merged into a respective single thread group;and

the shading stage is configured to:

execute the shader program for the identified thread groups, theexecuting the shader program for the identified thread groups including:

-   -   when thread groups of a respective identified set of mergeable        thread groups have reached the thread group merge event        indication, merging the thread groups into a single thread group        containing the active threads from each of the thread groups;        and    -   executing further instructions in the shader program after the        merge event indication point for the merged thread group.

The technology described herein relates to the execution of shaderprograms in graphics processing pipelines in which execution threads maybe grouped together into thread groups (“warps”). In the technologydescribed herein, thread groups that have some “non-active” (“helper”)threads are identified, and then a “merge event” indication is used totrigger the merging of those thread groups into a single thread groupfor execution containing the active threads of the thread groups duringthe shader execution. As will be discussed further below, this then hasthe effect of reducing the overall processing that is required in thesituation where thread groups have only some “active” threads (e.g.threads that relate to covered sampling positions).

The Applicants have recognised in this regard, that while, as discussedabove, it can be necessary to, when executing a fragment shader program,for example, execute that program for inactive (non-covered) “helperthreads”, e.g. for the purposes of generating inputs to samplingposition-delta type calculations, those calculations may only occur(and/or can be arranged only to occur) near the beginning of thefragment shader program. This then means that the inactive, “helper”threads can potentially be terminated once the calculations that theyare required for have been performed. Such early termination of the“helper threads” will in itself help to save power.

However, the Applicants have further recognised that even if a “helperthread” is terminated in this way, that will not in itself allow thethread group as a whole to be terminated (i.e. the “helper thread” willstill occupy a thread group execution lane even if it doesn't performany calculation, and thus unnecessarily occupy execution cycles, eventhough it is no longer needed to be processed). This can becomeparticularly wasteful for workloads with large numbers of smallprimitives and long shader programs (which are workloads frequently seenin modern games, for example).

The technology described herein addresses this by identifying andindicating a thread group merge event opportunity in the shader program,after which thread groups having inactive, “helper” threads are mergedinto a single thread group containing the “active” threads of theoriginal “sparsely” active thread groups. This then effectively avoidsthe inactive, “helper” threads of the original thread groups occupyingexecution cycles.

The thread groups that are considered in the technology described hereincan be any suitable and desired size. In some embodiments each threadgroup contains four threads (i.e. there is a warp width of four). Inthis case, in one embodiment each thread group (warp) corresponds to a2×2 sampling position “quad”. However, other arrangements, such as theuse of wider thread groups (warps) would be possible, if desired.

The programmable shading stage of the graphics processing pipeline cancomprise any suitable and desired programmable shading stage (“shader”)of the graphics processing pipeline. However, it is envisaged that thepresent application will have particular application to fragment shadingoperations, and thus in an embodiment the programmable shading stageoperates as (is operating as) a programmable fragment shading stage(fragment shader). The programmable shading stage may operate solely asa fragment shader, but it will be appreciated in this regard that theprogrammable shading stage may typically be able to (and in anembodiment can) run shaders other than just fragment shaders, i.e. suchthat there may be one or more programmable stages of the graphicsprocessing pipeline that may be appropriately programmed, e.g. atdifferent times, to function as a fragment shader (to perform fragmentshading operations) and to function as other forms (types) of shader.

Correspondingly the shader program that is issued to the (programmable)shader stage can be any suitable and desired shader program forexecution by the programmable shading stage, but in an embodiment is afragment shader program (a program for executing fragment shadingoperations) (and can comprise any suitable and desired fragment shaderprogram for execution by the programmable shading stage).

The program should (and in an embodiment does) produce some usefuloutput data, e.g. graphics processing output data for use in(subsequent) graphics processing operations, such as (an array of)vertex data, (an array of) fragment data etc. Thus, in an embodiment,the programmable execution unit executes a program so as to generate (anarray of) graphics processing output data.

The generated output data may be further processed (in an embodiment fordisplay), e.g. by a graphics processing pipeline, and/or provided to adisplay for display. Thus, in an embodiment, the generated output datais further processed, e.g. for display. In an embodiment, the generatedoutput data is used to provide an image for display, e.g. is provided toa display for display.

The render output that is being generated can be any suitable anddesired render output of a graphics processing pipeline. In oneembodiment the render output is a frame (image) to be displayed, but thetechnology described herein is equally applicable for other forms ofrender outputs, such as textures (in a render-to-texture operation),etc.

The thread group merge event indication that is included in the shaderprogram can take any suitable and desired form that can indicate (and beused by the shader to identify) the opportunity to merge thread groups.

In one embodiment the thread group merge indication is provided as or aspart of an instruction in the shader program. For example, the threadgroup merge indication could be provided as a specific instruction (a“merge” instruction) that is included in the shader program. It wouldalso be possible to indicate the thread group merge event opportunity bymeans of a modifier of or to an instruction in the shader program.

In other embodiments, the thread group merge event indication is notincluded as or as part of an instruction in the shader program, but isinstead indicated in some other way that can indicate the thread groupmerge event point in the shader program, such as a cutoff pointspecified separately from the shader program code itself. In this case,the merge event point could be indicated, e.g., as a specific number ofinstructions of the shader program having been executed, and/or aparticular program counter value being reached, whilst executing theshader program.

The thread group merge event indication can be provided in or inrelation to the shader program in any suitable and desired manner and byany suitable and desired element of the overall data processing system.

In an embodiment, the thread group merge event indication is provided bythe compiler (the shader compiler) for the graphics processing pipeline.Thus, in an embodiment, the compiler, e.g., inserts a thread group mergeevent instruction at the appropriate point in the, e.g. fragment, shaderprogram, or adds a thread group merge event modifier to an instructionin the shader program, or otherwise generates the indication of thecutoff point for the thread group merge event indication. Having thecompiler provide the thread group merge event indication has theadvantage that the compiler is able to assess the shader program todetermine if it is possible to include a thread group merge eventindication in the shader program execution.

In an embodiment, the compiler analyses the shader program code that isprovided, e.g. by the application on the host processor that requiresthe graphics processing, determines whether a thread group merge eventat some point in the shader program execution is possible, and if so,then provides the thread group merge event indication at and for theappropriate point in the shader program (e.g. by inserting a specificinstruction in the shader program at that point, or otherwise) toindicate the thread group merge event opportunity.

In an embodiment, the compiler is also operable to (where this ispossible) re-order operations in the shader program so as to, e.g.,provide an opportunity to include a thread group merge event in theshader program execution, and/or so as to allow for the more efficientinclusion and use of a thread group merge event opportunity in theexecution of the shader program.

In this regard, in an embodiment the compiler operates to place anyshader program operations that require results for inactive threads,such as texture lookups, before the thread group merge event indicationpoint. Correspondingly, in an embodiment the compiler places any shaderprogram operations, such as arithmetic operations, that do not need tobe executed for inactive (helper) threads in a thread group, after thethread group merge event point in the shader program execution.

The compiler may, e.g., and in an embodiment does, run on a hostprocessor of the overall data processing system that includes thegraphics processing pipeline (with the graphics processing pipeline thenbeing on another processor, such as a graphics processor, that isassociated with the host processor (such that the compiler and compiledcode run on separate processors within the overall data graphicsprocessing system)). However, other arrangements would be possible, suchas the compiler running on the same processor as the compiled code, orthe compiler being run on a (completely) separate processor, such as theprogram being precompiled on a separate system and being distributed ina compiled form.

The operation in the manner of the technology described herein toidentify and provide thread group merge event opportunities in a shaderprogram to be executed can be (and in one embodiment is) considered foreach and every shader program that is to be executed by the graphicsprocessing pipeline. It would also be possible to try to identify andprovide thread group merge event opportunities only for particularcategories or types of shader programs but not for other categories ortypes of shader programs (e.g. where the type of shader program isunlikely to offer useful thread group merge event opportunities).

In some embodiments the operation in the manner of the technologydescribed herein to identify and provide thread group merge eventopportunities is performed for fragment shader programs to be executed(and, in an embodiment, for each and every fragment shader program thatis to be executed by the graphics processing pipeline).

(However, it is not necessary that each and every, e.g. fragment, shaderprogram has to have a thread group merge event indication and pointincluded in it, for example where the compiler determines that asuitable merge event point does not exist or may not be so useful in theshader program in question.)

It would also be possible to include multiple thread group merge eventpoints in a shader program, if desired. This could be useful when, forexample, the bulk of the shader program is contained in an IF-block,such that it might be appropriate to put one merge point in the middleof the IF-block and a second merge point just after the end of theIF-block in the shader program execution. In this case, in an embodimentall the active threads in a thread group have to hit at least one of themerge points before the merge event can take place.

The technology described herein also extends to the compiler itself.

Thus, another embodiment of the technology described herein comprises acompiler that compiles programs to generate instructions for a shadingstage of a graphics processing pipeline that executes instructions toperform shading operations, and in which execution threads may begrouped together into thread groups in which the threads of the groupare executed in lockstep, one instruction at a time;

wherein the compiler is configured to, for a shader program to beexecuted by a shader stage:

determine whether there is a point within the execution of the shaderprogram where two or more thread groups each having inactive threads maybe merged; and

when it is determined that there is a point in the shader programexecution where two or more thread groups having inactive threads may bemerged, include in or provide with the shader program, a thread groupmerge event indication that indicates a point in the shader programexecution where two or more thread groups, each having inactive threads,may be merged.

Another embodiment of the technology described herein comprises a methodof compiling a program to generate instructions for a shading stage of agraphics processing pipeline that executes instructions to performshading operations, and in which execution threads may be groupedtogether into thread groups in which the threads of the group areexecuted in lockstep, one instruction at a time;

the method comprising, for a shader program to be executed by a shaderstage:

determining whether there is a point within the execution of the shaderprogram where two or more thread groups each having inactive threads maybe merged; and

when it is determined that there is a point in the shader programexecution where two or more thread groups having inactive threads may bemerged, including in or providing with the shader program, a threadgroup merge event indication that indicates a point in the shaderprogram execution where two or more thread groups, each having inactivethreads, may be merged.

The technology described herein also extends to a shader stage of agraphics processing pipeline that can merge thread groups in response toa thread group merge indication for a shader program being executed bythe shader stage.

Thus, another embodiment of the technology described herein comprises ashader stage of a graphics processing pipeline that executesinstructions to perform shading operations, and in which executionthreads may be grouped together into thread groups in which the threadsof the group are executed in lockstep, one instruction at a time, theshader stage being configured to:

when executing instructions of a shader program, in response to a threadgroup merge event indication that indicates a point in the shaderprogram execution where two or more thread groups may be mergedassociated with the shader program:

determine whether two or more thread groups for which the shader programis being executed and that can be merged into a single thread groupexist; and

when two or more thread groups which may be merged into a single threadgroup exist, merge the thread groups into a single thread groupcontaining the active threads from each of the thread groups; and

execute further instructions in the shader program after the merge eventindication for the merged thread group.

Another embodiment of the technology described herein comprises a methodof operating a shader stage of a graphics processing pipeline thatexecutes instructions to perform shading operations, and in whichexecution threads may be grouped together into thread groups in whichthe threads of the group are executed in lockstep, one instruction at atime;

the method comprising the shader stage, when executing instructions of ashader program, in response to a thread group merge event indicationthat indicates a point in the shader program execution where two or morethread groups may be merged associated with the shader program:

determining whether two or more thread groups for which the shaderprogram is being executed and that can be merged into a single threadgroup exist; and

when two or more thread groups which may be merged into a single threadgroup exist, merging the thread groups into a single thread groupcontaining the active threads from each of the thread groups; and

executing further instructions in the shader program after the mergeevent indication for the merged thread group.

As will be appreciated by those skilled in the art, these embodiments ofthe technology described herein can and, for some embodiments do includeany one or more or all of the optional features of the technologydescribed herein, as appropriate. Thus, for example, in an embodimentthe shader program is a fragment shader program, and, correspondingly,in an embodiment the shader stage is (operating as) a fragment shaderstage of the graphics processing pipeline.

The identification of a set (of the sets) of two or more thread groupsfor which not all the threads in the thread groups are active, and whichmay be merged into a single thread group, can be performed in anysuitable and desired manner by, and element of, the graphics processingpipeline. This may depend, for example, upon the shader program andshader stage that is being executed.

In an embodiment, at least in the case of the shader program being afragment shader program (and accordingly the programmable shading stageacting as a fragment shading stage (fragment shader)), the rasteriser ofthe graphics processing pipeline identifies the set or sets of two ormore thread groups for which not all the threads in the thread groupsare active, which may be merged into a single thread group, e.g., and inan embodiment, as it rasterises primitives to generate fragments, e.g.quads (or other groupings) of sampling positions, for rendering.

As discussed above, the rasteriser of the graphics processing pipelinewill test primitives to be rendered against sampling positions of therender output being generated, and generate fragments to be rendered foreach sampling position (or respective set of sampling positions (e.g.each 2×2 quad of sampling positions)) that is covered by (or thatincludes at least one sampling position that is covered by) theprimitive in question.

The fragments that are generated by the rasteriser for rendering aprimitive are then sent to the rest of the graphics processing pipeline(including the fragment shading stage) for processing. Each fragmentwill accordingly correspond to and be used to render a set of samplingpositions (with each set of sampling positions comprising one samplingposition or plural sampling positions, depending upon whether thefragments represent individual sampling positions or sets, e.g. quads,of plural sampling positions).

Then, at the fragment shading stage each fragment (i.e. the set ofsampling positions that the fragment represents) will be processed as arespective thread group (warp), with each thread (and thus executionlane) in and for the thread group corresponding to a given samplingposition in the set of sampling positions that the fragment represents.Covered sampling positions in the set of sampling positions for afragment will thus be active threads of the thread group, and uncoveredsampling positions will be inactive (“helper”) threads of the threadgroup (warp).

All the thread groups in a set of thread groups to be (potentially)merged should, and in an embodiment do, run (execute) the same shaderprogram. So long as this requirement is met, there is no need for thethread groups in a set of thread groups to be (potentially) merged tootherwise be associated in any particular way.

However, other requirements could be set, if desired. For example, thethread groups to be merged could have to belong to the same draw call(and in an embodiment this is what is done). Similarly, the threadgroups in a set of thread groups to be (potentially) merged could haveto relate to the same graphics primitive. However, this is notessential, and in an embodiment the thread groups in a set of threadgroups to be (potentially) merged can relate to different primitives.Permitting thread groups in different primitives to be merged can beadvantageous, especially in the case where the average primitive size isone sampling position quad or smaller.

The thread groups that are included in a set of thread groups to be(potentially) merged should each have at least one inactive thread (e.g.an uncovered sampling point), but can otherwise be selected as desired.

In one embodiment the (and each) set of thread groups that may be mergedinto a single thread group contains only two thread groups (i.e. pairsof thread groups that may be merged into, single thread groups areidentified). However, it would also be possible to identify sets ofthree or more thread groups (warps) that may be merged into a singlethread group, if desired.

The thread groups to be (potentially) merged should, and in anembodiment do, total between them no more than the maximum number ofactive threads that a single thread group can contain (as that thenallows all the active threads for the thread groups to be merged into asingle thread group). In an embodiment, thread groups that will combineto provide a “full” merged, single thread group are preferentiallyidentified as merger candidates.

In an embodiment thread groups having non-overlapping active threads(i.e. for which the active threads reside in different thread group(warp) lanes) are identified as being thread groups that can be mergedinto a single thread group.

In one embodiment, only thread groups having non-overlapping activethreads (i.e. for which the active threads reside in different threadgroup (warp) lanes) are identified as being thread groups that can bemerged into a single thread group.

However, in some embodiments, it is possible to (e.g., and in anembodiment the rasteriser is able to) re-map the allocation of threads(e.g. sampling positions) to thread group lanes for thread groups (e.g.by flipping the 2×2 quad that the thread group corresponds tohorizontally or vertically), so as to (try to) remove the overlap forthread groups that in their initial configuration have overlappingactive threads (lanes), to allow such thread groups then to be(potentially) merged.

Thus, in some embodiments, the, e.g., rasteriser, is able to remap theassociation of, e.g. sampling positions, that a thread group representsto the thread group execution (warp) lanes, so as to, for example, andin an embodiment, be able to remove active thread execution (warp) laneoverlap between different thread groups.

In this case, in an embodiment, the remapping (reorientation) for aremapped thread group is tracked or otherwise recorded in some way so asto allow the, e.g. fragment, shading operation to still ensure that anyshading operations performed on a “remapped” thread group are calculatedcorrectly, and to allow the final results for the remapped thread groupto be “unmapped” as needed, e.g. when they are to be committed to anoutput.

In an embodiment, the process of identifying sets of thread groups thatcan be merged is repeated, e.g. as fragments are generated for renderingby the rasteriser, as primitives are being rasterised, and/or as therender output in question is being generated. Thus, in some embodiments,plural pairs (or other sets) of thread groups that may be merged intosingle thread groups are identified. In an embodiment the, e.g.,rasteriser, operates to identify pairs (or other groups) of threadgroups that may be merged into respective single thread groups as itoperates to rasterise primitives for rendering.

In some embodiments, the identified thread groups that can be mergedinto a respective single thread group are indicated to the shader stageof the graphics processing pipeline, so that the shader stage canidentify the thread groups that have been identified (associated) as“merge” candidates when they reach the thread group merge eventindication point in the shader program execution. This can be done inany suitable and desired manner. For example, and in an embodiment, therasteriser can signal to the fragment shader stage those thread groupsthat can be merged together, as it issues the thread groups to thefragment shader.

In one way in which this could be done, the rasterizer keeps at itsoutput a (e.g. small) queue of partial thread groups. When therasterizer generates a new partial thread group, it will then match itagainst (compare it with) the partial thread groups in the queue in anattempt to find an earlier thread group with which it can be merged. Ifsuccessful (i.e. if a suitable earlier thread group is found in thequeue), the two thread groups can be issued to the fragment shadertogether. If not, the new partial thread group is inserted into thequeue. It is possible that such a queue may become full, in which caseunmerged partial thread groups could be passed into the fragment shader.

The technology described herein also extends to the operation of arasteriser of a graphics processing pipeline identifying thread groupsthat may be merged into a single thread group.

Thus, another embodiment of the technology described herein comprises amethod of operating a rasteriser of a graphics processing pipeline,which rasteriser rasterises graphics primitives to be rendered intographics fragments for rendering, each graphics fragment representing aset of plural sampling positions of a render output to be generated;

the method comprising the rasteriser:

identifying fragments for a primitive that include sampling positionsthat are not covered by the primitive and determining whether any ofthose fragments could be merged to form a single fragment thatrepresents all the covered sampling points of the fragments; and

when it is determined that two or more fragments that include uncoveredsampling positions can be merged to form a single fragment thatrepresents all the covered sampling points of the fragments, signallingto a fragment shading stage of the graphics processing pipeline that thetwo or more fragments that include uncovered sampling positions can bemerged to form a single fragment that represents all the coveredsampling points of the fragments.

Another embodiment of the technology described herein comprises arasteriser for a graphics processing pipeline, which rasteriserrasterises graphics primitives to be rendered into graphics fragmentsfor rendering, each graphics fragment representing a set of pluralsampling positions of a render output to be generated;

wherein the rasteriser is configured to:

identify fragments for a primitive that include sampling positions thatare not covered by the primitive and determine whether any of thosefragments could be merged to form a single fragment that represents allthe covered sampling points of the fragments; and

when it is determined that two or more fragments that include uncoveredsampling positions can be merged to form a single fragment thatrepresents all the covered sampling points of the fragments, signal to afragment shading stage of the graphics processing pipeline that the twoor more fragments that include uncovered sampling positions can bemerged to form a single fragment that represents all the coveredsampling points of the fragments.

As will be appreciated by those skilled in the art, these embodiments ofthe technology described herein can and in some embodiments do includeany one or more or all of the optional features of the technologydescribed herein, as appropriate.

In some embodiments, the thread groups of a (and, in an embodiment, ofeach) set of thread groups that have been identified as being able to bemerged into a single thread group are issued consecutively to theshading stage (although this is not essential and other arrangementswould be possible).

Similarly, in some embodiments, any thread groups that are potentiallyto be merged with each other into a single thread group are issued tothe shader stage for execution in a manner that is appropriate to andconsistent with any restrictions for the handling of thread groups inthe graphics processing pipeline. Thus, for example, in an embodimentwhere there are plural different register and/or memory banks availablefor the use of thread groups, any thread groups that are potentially tobe merged with each other are issued to the shader stage for executionin such a manner that they will share the same memory bank and/or set ofregisters, etc.

The Applicants have further recognised that not all thread groups to beexecuted will be able to be (potentially) merged with another threadgroup or groups (e.g. because all the threads in the thread group (e.g.quad) are active or there is not another suitable thread group that thethread group could be merged with).

Thus, in an embodiment, if a thread group to be issued to the shaderstage is identified (e.g. by the rasteriser) as being unable to be(potentially) merged with another thread group, then the thread groupis, in an embodiment, indicated as being unable to be merged (as to beprocessed as a single thread group). This indication could, e.g.,comprise simply omitting any indication that the thread group can bemerged with another thread group.

Once the thread groups have been issued to the, e.g. fragment, shadingstage, the shading stage will execute the shader program for the threadgroups. Then, when the identified thread groups that may be merged intoa single thread group have reached the thread group merge eventindication, those thread groups are merged into a single thread groupcontaining the active threads from each of the thread groups.

This may be implemented as desired, but in an embodiment when the firstthread group of the set of thread groups that are to be merged reachesthe thread group merge point in the shader program execution (e.g.reaches the thread group merge instruction), shader program executionfor that thread group is stalled until the other thread group or groupsthat it is to be merged with have also reached the thread group mergepoint in the shader program execution. Then, once all (e.g. both) thethread groups that are to be merged have reached the thread group mergepoint in the shader program execution, the thread groups are merged intoa single thread group containing the active threads from each of thethread groups.

The merging of the thread groups into a single thread group containingthe active threads from each of the thread groups can be performed asdesired. In some embodiments the active threads from each warp group aremapped to respective thread group (warp) lanes of the merged, singlethread group (warp). In an embodiment one of the thread groups of thegroup of thread groups that is to be merged is retained as the singlethread group containing the active threads from each of the threadgroups, with the other thread group or groups in the set of threadgroups that are to be merged then being terminated.

In an embodiment, after the thread group merge event, the thread groupsthat are merged proceed as one shared thread group (warp), sharing asingle (active) program counter.

In execution of the shader program, any inactive threads that have notyet been terminated are, in an embodiment, terminated when the threadgroups are merged. (In an embodiment any inactive “helper” threads in athread group are terminated once the operations that they are requiredfor have been performed.)

Once the associated thread groups have been merged into a single threadgroup, further instructions in the shader program are executed for themerged thread group. In an embodiment, the execution of the remaininginstructions in the shader program after the merge event indicationpoint is completed (appropriately) for the merged thread group.

As discussed above, there may be thread groups that cannot be mergedwith other thread groups. In an embodiment, when such an “unmergeable”thread group reaches the thread group merge event indication point inthe shader program execution, the thread group merge event indication isignored (has no effect), and the shader program is simply continued tobe executed for the thread group on its own (i.e. the instructions inthe shader program after the merge event indication point are executedfor the thread group on its own). In other words, in an embodiment, forany thread groups that are not identified as being able to be mergedwith another thread group, the thread group merge event indication willhave no effect on the execution of the shader program for the threadgroup.

The shader program that is executed by the shading stage for the threadgroups will typically perform a sequence of instructions that read andwrite data from and to respective registers. In an embodiment, theregisters that data is read from and written to when executing theshader program for the thread groups are arranged in a particularmanner, as that will then, as discussed below, help to facilitate thethread group merging operation.

Thus, in some embodiments, the registers that are allocated for use bythe shader program (while the shader program is being executed) aredivided into two subsets, a set of “common” registers that arephysically shared by the thread groups in the set of thread groups thatare to be merged into the single thread group, in an embodiment from thestart of the execution of the shader program for the thread groups, anda set of “private” registers that are sets of registers that arerespectively local (and exclusive) to each thread group in the set andinaccessible to the other thread group or groups in the set of threadgroups that are to be merged (i.e. each thread group in the set willhave its own set of “private” registers that only it can access).

The division of the registers into “common” and “private” subsets can bedone in any suitable and desired manner. In one embodiment, a registerindex cutoff is used to divide the registers in this way, with allregisters below the cutoff being “common” registers and all registersabove the cutoff being “private” registers (or vice-versa). The registerindex cutoff may, e.g., and in an embodiment, be specified by thecompiler. Other arrangements for dividing the registers into “common”and “private” subsets may also or instead be used, if desired, such ashaving a hard coded division of the registers, or a bitmap indicatingwhich registers go into which subset.

In an embodiment, the common and private registers for the thread groupsare then used and handled in the following manner.

Firstly, before the thread group merge point in the shader programexecution, a thread group can, in an embodiment, freely both read andwrite for all threads (lanes) of the group to and from the privateregisters for that thread group (i.e. for both “real” (active) and“helper” (inactive) threads).

Correspondingly, in an embodiment, before the thread group merge pointin the shader program execution a thread group can only write to the“common” registers for the set of thread groups for active threads (forlanes containing “real” (active) threads).

Similarly, in an embodiment, before the thread group merge point in theshader program execution, the reading of the common registers by thethread groups is restricted. For example, in an embodiment the threadgroups cannot read the common registers at all, or only read the commonregisters for those lanes containing “real” threads (for the activethreads of the thread groups), and/or the thread groups only read actualvalues in the lanes containing “real” (active) threads, with the lanesthat contain “helper” (inactive) threads receiving default values (e.g.all zeros).

This helps to prevent communication between the thread groups before thethread group merge event.

After the thread groups have been merged (the merge event has beenperformed), in an embodiment the contents of the “private” registers forthe thread groups that were merged are invalidated (and thus only thecommon registers for the thread groups that were merged are consideredto have valid values).

The access to the private register space could correspondingly beblocked altogether for the merged, single thread group. However, in anembodiment, a new set of private registers is allocated for the merged,single thread group. This may be done as desired, for example by mappingthe private registers of one of the thread groups into the registerspace of the single, merged thread group, or by, upon the merge event,mapping a fresh set of private registers into the register space for themerged thread group, or by combining the private registers of both ofthe thread groups to give a larger private register space for themerged, single thread group.

Where the shader program includes multiple thread group merge eventpoints, then the merged private registers may only, and in an embodimentdo only, become available after the last merge point.

Corresponding to the above arrangements of common and private registersfor the thread groups, in some embodiments, any instruction thatrequires the use of inactive (“helper”) threads is performed before themerge event point in the shader program execution, and in an embodimentuses the private registers for the thread group in question.

Thus, in some embodiments, any instruction that performs across-sampling point calculation (such as pixel-delta, mipmap texturelookup) occurs before the thread group merge event point and usesprivate registers as its inputs, and/or any instruction whose result canpotentially be an input into a cross-sampling point calculation occursbefore the merge event point and writes its result to private registers.

Correspondingly, in an embodiment, any data item from before the mergeevent point that needs to be preserved across the thread group mergeevent (i.e. is to be available for the merged, single thread group afterthe merge event) is stored in the common register(s) (before the mergeevent).

This then means that it can be safely assumed that after the threadgroup merge event, the contents of the private registers of the threadgroups are no longer required, such that those private registers canthen be invalidated and/or reused as private registers for the mergedthread group.

In some embodiments, the shader program operations (code) are organised(configured), e.g. by the compiler that compiles the shader programcode, to achieve this.

The above subdivision and handling of registers for the thread groupsthat are (potentially) to be merged during execution of the shaderprogram facilitates the merging of the thread groups being performedwithout the need to actually physically move any data between registersfor the merge operation.

In the event that it is necessary to spill some of the registers for athread group to stack (which may occur, e.g., when running fragmentshaders with very large data working sets), then again two stacks, one“private” and one “common” in the manner discussed above for theregisters could be used. However, this is not necessary, and in anotherembodiment, in this event a single stack is used but which isinvalidated at the merge event. To facilitate this operation, the shaderprogram is, in an embodiment, configured (e.g. by the compiler) suchthat the stack will be empty at the time of the merge event. (If thiscannot be guaranteed at any of the points in the shader program thatwould otherwise be useful as thread group merge event points, then, inan embodiment, a shader program without any thread group merge eventpoints is generated.)

The above describes an operation where plural thread groups are mergedinto a single thread group during shader program operation. TheApplicants have recognised that the converse operation, namely to“demerge” a single thread group into plural thread groups could also beuseful.

For example, there are some graphics processing operations, such assample frequency shading, in which multiple (e.g. four) sampling pointsare processed for each sampling position within a render output to begenerated. In this case each set of sampling points for a given samplingposition can be processed as one thread group (warp) (i.e. such thatthere will be one thread group for each sampling position of the renderoutput to be processed). However, the Applicants have recognised that inthese operations, as well as there being per-sampling point calculationsthat need to be done, there can be some calculations that need to bedone identically for each sampling point for a given sampling position,and so that can, in effect, be done per-sampling position. Theseper-sampling position calculations would not require a full thread groupfor each sampling position but rather a single thread group (lane) couldperform the calculation for a given sampling position.

This being the case, the Applicants have recognised that, for example, asingle thread group (warp) could be used to perform per-samplingposition calculations for a set of plural sampling positions, withplural individual thread groups then being used to perform theper-sampling point calculations for the sampling positions. Thus, if thefragment shader program, for example, is or can be configured such thatthe per-sampling position operations are performed first, it would bepossible for the fragment shader execution for a given set of samplingpositions to start with a single thread group while the per-samplingposition calculations are being performed, with the thread group thenbeing split (“demerged”) into plural thread groups to perform theper-sampling point operations (calculations).

Thus, another embodiment of the technology described herein comprises amethod of operating a graphics processing pipeline which includes aprogrammable shading stage that executes instructions to perform shadingoperations, in which execution threads may be grouped together intothread groups in which the threads of the group are executed inlockstep, one instruction at a time, the method comprising:

issuing to the shader stage a shader program for execution by the shaderstage to process execution threads for generating a render output,together with a thread group divide event indication that indicates apoint in the shader program execution where a single thread group is tobe divided into plural separate thread groups; and

the shading stage:

-   -   executing the shader program for a thread group, the executing        the shader program for the thread group including:        -   when the thread group reaches the thread group divide event            indication, dividing the single thread group into a            plurality of separate thread groups; and        -   executing further instructions in the shader program after            the divide event indication point for the plurality of            separate thread groups.

Another embodiment of the technology described herein comprises a dataprocessing system comprising:

a graphics processing pipeline that includes a programmable shadingstage that executes instructions to perform shading operations, and inwhich execution threads may be grouped together into thread groups inwhich the threads of the group are executed in lockstep, one instructionat a time, and

a compiler that compiles programs for the shading stage to generateinstructions for execution by the shading stage;

wherein the compiler is configured to:

issue to the shader stage a shader program for execution by the shaderstage to process execution threads for generating a render output,together with a thread group divide event indication that indicates apoint in the shader program execution where thread groups are to bedivided into plural separate thread groups; and

the shading stage is configured to:

execute the shader program for thread groups, the executing the shaderprogram for the thread groups including:

-   -   when a thread group reaches the thread group divide event        indication, dividing the single thread group into a plurality of        separate thread groups; and    -   executing further instructions in the shader program after the        divide event indication point for the plurality of separate        thread groups.

In these embodiments of the technology described herein, a thread groupthat is being processed is divided into plural separate thread groupsafter a certain point in the shader program execution. This then allows,for example, per sampling position calculations that need to be doneidentically for every sample point for the sampling position to beprocessed as a single thread group, with the per sampling pointcalculations then being performed once the single thread group has beendivided into the plurality of separate thread groups. This avoids theneed, for example, to expend processing resources (such as executioncycles) for calculations for sampling points that are not in factrequired.

As will be appreciated by those skilled in the art, these embodiments ofthe technology described herein can and in some embodiments do includeany one or more or all of the optional features of the technologydescribed herein, as appropriate.

Thus, for example, in some embodiments the shader program is a fragmentshader program, and, correspondingly, in some embodiments the shaderstage is (operating as) a fragment shader stage of the graphicsprocessing pipeline.

Thus, for example, the thread groups can be any suitable and desiredsize. In an embodiment each initial single thread group contains fourthreads (i.e. there is a warp width of four). In an embodiment, thethread groups after the divide event contain the same number of threadsas the initial single thread group (so, e.g., 4 threads).

Similarly, in some embodiments the thread group divide event indicationthat is included in the shader program is provided in one of the mannersdiscussed above (thus as or as part of an instruction in the shaderprogram, by means of a modifier of or to an instruction in the shaderprogram, or in some other way that can indicate the thread group divideevent point in the shader program, such as a cutoff point specifiedseparately from the shader program code itself).

In an embodiment, the thread group divide event indication is againprovided by the compiler (the shader compiler) for the graphicsprocessing pipeline.

In an embodiment, the compiler analyses the shader program code that isprovided, e.g. by the application on the host processor that requiresthe graphics processing, determines whether a thread group divide eventat some point in the shader program execution is possible, and if so,then provides the thread group divide event indication at and for theappropriate point in the shader program (e.g. by inserting a specificinstruction in the shader program at that point, or otherwise) toindicate the thread group divide event point.

In an embodiment, the compiler is also operable to (where this ispossible) re-order operations in the shader program so as to, e.g.,provide an opportunity to include a thread group divide event in theshader program execution, and/or so as to allow for the more efficientinclusion and use of a thread group divide event in the execution of theshader program.

In this regard, in an embodiment the compiler operates to place anyshader program operations that perform per-sampling positioncalculations before the thread group divide event indication point.Correspondingly, in an embodiment the compiler places any shader programoperations that perform per-sampling point calculations after the threadgroup divide event point in the shader program execution.

These embodiments of the technology described herein again extend to thecompiler operation per se.

Thus, another embodiment of the technology described herein comprises acompiler that compiles programs to generate instructions for a shadingstage of a graphics processing pipeline that executes instructions toperform shading operations, and in which execution threads may begrouped together into thread groups in which the threads of the groupare executed in lockstep, one instruction at a time;

wherein the compiler is configured to, for a shader program to beexecuted by a shader stage:

determine whether the shader program includes both operations that mustbe performed individually for threads to be executed and operations thatcan be performed collectively for groups of threads to be executed; and

when it is determined that the shader program includes both operationsthat must be performed individually for threads to be executed andoperations that can be performed collectively for groups of threads tobe executed, include in or provide with the shader program a threadgroup divide event indication that indicates a point in the shaderprogram execution where a thread group should be divided into pluralseparate thread groups, the thread group divide point being after theoperations that can be performed collectively for groups of threads tobe executed in the shader program, and before one or more (and in anembodiment all) of the operations that must be performed individuallyfor threads to be executed in the shader program.

Another embodiment of the technology described herein comprises a methodof compiling a program to generate instructions for a shading stage of agraphics processing pipeline that executes instructions to performshading operations, and in which execution threads may be groupedtogether into thread groups in which the threads of the group areexecuted in lockstep, one instruction at a time;

the method comprising, for a shader program to be executed by a shaderstage:

determining whether the shader program includes both operations thatmust be performed individually for threads to be executed and operationsthat can be performed collectively for groups of threads to be executed;and

when it is determined that the shader program includes both operationsthat must be performed individually for threads to be executed andoperations that can be performed collectively for groups of threads tobe executed, including in or providing with the shader program a threadgroup divide event indication that indicates a point in the shaderprogram execution where a thread group should be divided into pluralseparate thread groups, the thread group divide point being after theoperations that can be performed collectively for groups of threads tobe executed in the shader program, and before one or more (and in anembodiment all) of the operations that must be performed individuallyfor threads to be executed in the shader program.

These embodiments of the technology described herein correspondinglyalso extend to a shader stage of a graphics processing pipeline that candivide thread groups in response to a thread group divide indication fora shader program being executed by the shader stage.

Thus, another embodiment of the technology described herein comprises ashader stage of a graphics processing pipeline that executesinstructions to perform shading operations, and in which executionthreads may be grouped together into thread groups in which the threadsof the group are executed in lockstep, one instruction at a time, theshader stage being configured to:

when executing instructions of a shader program, in response to a threadgroup divide event indication that indicates a point in the shaderprogram execution where thread groups should be divided into pluralseparate thread groups, associated with the shader program:

divide a thread group into a plurality of separate thread groups; and

execute further instructions in the shader program after the divideevent indication for the plurality of separate thread groups.

Another embodiment of the technology described herein comprises a methodof operating a shader stage of a graphics processing pipeline thatexecutes instructions to perform shading operations, and in whichexecution threads may be grouped together into thread groups in whichthe threads of the group are executed in lockstep, one instruction at atime;

the method comprising the shader stage, when executing instructions of ashader program, in response to a thread group divide event indicationthat indicates a point in the shader program execution where threadgroups should be divided into plural separate thread groups, associatedwith the shader program:

dividing a thread group into a plurality of separate thread groups; and

executing further instructions in the shader program after the divideevent indication for the plurality of separate thread groups.

As will be appreciated by those skilled in the art, these embodiments ofthe technology described herein can and in some embodiments do includeany one or more or all of the optional features of the technologydescribed herein, as appropriate. Thus, for example, in an embodimentthe shader program is a fragment shader program, and, correspondingly,in an embodiment the shader stage is (operating as) a fragment shaderstage of the graphics processing pipeline.

In these embodiments and embodiments of the technology described herein,once the thread groups have been issued to the shading stage, theshading stage will execute the shader program for the thread groups.Then, when a (and in an embodiment when each) thread group reaches thethread group divide event indication, the thread group is divided intoplural separate thread groups. More than one thread group divide eventpoint (and indication) could be included in a shader program, ifdesired. In this case, divided thread groups may be divided again whenthey reach a later divide point in the shader program execution.

The number of thread groups that the initial single thread group isdivided into can be selected as desired, and may, e.g., and in anembodiment, depend upon the size of the thread groups that the shadersupports and the number of sampling points to be considered for eachsampling position.

Thus, for example, and in an embodiment, the initial single thread groupcould be divided into plural separate thread groups, each representingone of the threads (lanes) from the initial single thread group. Thismay be appropriate where, for example, each sampling position has anumber of sampling points associated with it that corresponds to thenumber of threads that the thread groups in the shader can contain. Inthis case the (and in an embodiment each) initial thread group will bedivided into as many separate thread groups as there were threads in theinitial thread group.

Alternatively or additionally, sampling points from different samplingpositions could be processed using the same thread group. For example,the sampling points for a respective sampling point position for each ofthe sampling positions that the initial single thread group representscould be processed as a respective thread group after the initial singlethread group has been divided. In this case, the initial thread groupwould be divided into plural separate thread groups, each representing,e.g. and in an embodiment, the sampling points from one of therespective sampling point positions for each of the threads (lanes) fromthe initial single thread group. Thus, in this case, the (and in anembodiment each) initial thread group would be, and in an embodiment is,divided into as many separate thread groups as there are sampling pointsper sampling position to be processed.

After the thread group divide event, further instructions in the shaderprogram are executed for the divided thread group (the plural separatethread groups). In an embodiment, the execution of the remaininginstructions in the shader program after the divide event indicationpoint is completed (appropriately) for the plural separate threadgroups.

In come embodiments of the technology described herein, the registersthat data is read from and written to when executing the shader programfor the thread groups are arranged in a particular manner, as that willagain help to facilitate the thread group dividing operation.

Thus, in some embodiments, the registers used during execution of theshader program are again divided into two subsets, a set of “common”registers that are physically shared by the initial single thread groupand the thread groups in the set of thread groups that are to be dividedfrom the single thread group, in an embodiment from the start of theexecution of the shader program, and a set of “private” registers thatare sets of registers that are respectively local (and exclusive) toeach thread group and inaccessible to the other thread group or groups(i.e. each thread group (both the initial single thread group and thethread groups in the set of thread groups that the single thread groupis divided into) will have its own set of “private” registers that onlyit can access).

In some of these arrangements, before the thread group divide point inthe shader program execution, the initial “single” thread group uses thecommon registers for the thread group(s) for its calculations (and thus,in an embodiment can freely both read and write for all threads (lanes)of the group to and from the common registers for the thread group(s)).

Then, in some embodiments, after the initial single thread group hasbeen divided (the divide event has been performed), the common registersfor the thread group that was divided are treated as a read-onlyregister(s) (so as to preserve the per-sampling position values), and insome embodiments calculations performed after the thread group divideevent use (and in an embodiment, only use) the private registers for thethread group in question.

In some embodiments, the shader program operations (code) are organised(configured), in an embodiment by the compiler that compiles the shaderprogram code, to achieve this. Correspondingly, appropriate private andcommon registers can be reserved for the thread groups before the shaderprogram execution is started.

The above subdivision and handling of registers for the thread groupsthat are to be divided during execution of the shader programfacilitates the dividing of the thread groups being performed withoutthe need to actually physically move any data between registers for thedivide operation.

It would be possible, if desired, to include both a thread group mergeevent opportunity and a thread group divide event in a given shaderprogram. However, the Applicants believe that in most circumstances itwill be appropriate to include one or other of these events in a givenshader program, but not both.

It will be appreciated from the above, that in both the thread groupmerge and thread group divide operations of the technology describedherein, an important feature is the arrangement of the registers thatthe threads and thread groups use into “private” and “common” registers.It is believed that such an arrangement of the registers that are usedby thread groups when a shader program is being executed may be new andadvantageous in its own right.

Thus, a yet further embodiment of the technology described hereincomprises a method of allocating registers for use by thread groups whenexecuting instructions to perform processing operations in a graphicsprocessing pipeline which includes programmable shading stages thatexecute instructions to perform shading operations, and in whichexecution threads may be grouped together into thread groups in whichthe threads of the groups are executed in lockstep, one instruction at atime, the method comprising:

providing for use for a thread group for which a shader program is to beexecuted by a programmable shading stage of the graphics processingpipeline during execution of the shader program, a common register orregisters that is to be shared with other thread groups for which theshader program is to be executed, and a private register or registersthat is local (exclusive) to the thread group and inaccessible to otherthread groups for which the shader program is to be executed.

A yet further embodiment of the technology described herein comprises agraphics processing pipeline comprising:

one or more programmable shading stages that execute instructions toperform shading operations, and in which execution threads may begrouped together into thread groups in which the threads of the groupsare executed in lockstep, one instruction at a time; and

a plurality of registers for use by thread groups when executinginstructions to perform processing operations; wherein:

the plurality of registers are arranged in use so as to provide for usefor a thread group for which a shader program is to be executed by aprogrammable shading stage of the graphics processing pipeline, duringexecution of the shader program, a common register or registers that isshared with other thread groups for which the shader program is to beexecuted, and a private register or registers that is local to thethread group and inaccessible to other thread groups for which theshader program is to be executed.

As will be appreciated by those skilled in the art, these embodiments ofthe technology described herein can and some embodiments do include anyone or more or all of the optional features of the technology describedherein, as appropriate.

Thus, in an embodiment, for example, the subdivision of the registersinto common and private registers is performed in one of the mannersdiscussed above.

Correspondingly, in an embodiment the shader program execution uses thecommon register or registers for the thread group for certain, e.g.selected, operations, and uses the private register or registers for thethread group for other, e.g. selected, operations.

Similarly, in an embodiment, the use of the common and private registersfor shader program operations for the thread group is varied and/orselected based upon the point within the shader program that has beenreached.

The fragment shader of the graphics processing pipeline can beimplemented as desired and in any suitable manner, and can perform anydesired and suitable fragment shading functions, as appropriate. It may,for example, render a primitive or primitives to generate a set ofrender output values, e.g. representing a frame for display. Theseoutput values may then be exported to external memory for storage anduse, such as to a frame buffer for a display.

As well as a fragment shader, the programmable processing stage(s) ofthe graphics processing pipeline may function (operate) as (the graphicsprocessing pipeline may include) other shader stages (shaders), such asa vertex shader, a geometry shader, etc., if and as desired.

Each programmable processing stage (execution unit), of the graphicsprocessing pipeline may comprise any suitable programmable hardwareelement such as programmable processing circuitry. Each programmableprocessing stage may be provided as a separate circuit element to otherprogrammable stages of the processing pipeline or the programmableprocessing stages may share some or all of their programmable processingcircuitry (that is then differently programmed to serve as the desiredprogrammable processing stage).

As well as any programmable processing (shader) stages, the graphicsprocessing pipeline may also contain any other suitable and desiredprocessing stages that a graphics processing pipeline may contain suchas a rasteriser, an early depth (or an early depth and stencil) tester,a late depth (or depth and stencil) tester, a blender, a tile buffer, awrite out unit, etc.

The technology described herein can be used for all forms of output thata graphics processing pipeline may be used to generate, such as framesfor display, render-to-texture outputs, etc. In some embodiments, theoutput, e.g. fragment shaded, data values from the graphics processingare exported to external, e.g. main, memory, for storage and use, suchas to a frame buffer for a display.

In some embodiments, the graphics processing pipeline comprises, and/oris in communication with, one or more memories and/or memory devicesthat store the data described herein, and/or store software forperforming the processes described herein. The graphics processingpipeline may also be in communication with a host microprocessor, and/orwith a display for displaying images based on the data generated by thegraphics processor.

The technology described herein is applicable to any suitable form orconfiguration of graphics processor. It is particularly applicable totile-based graphics processors and graphics processing systems. Thus inan embodiment, the graphics processing system and graphics processingpipeline are a tile-based system and pipeline, respectively.

In an embodiment, the various functions of the technology describedherein are carried out on a single graphics processing platform thatgenerates and outputs the rendered fragment data that is, e.g., writtento the frame buffer for the display device.

The technology described herein can be implemented in any suitablesystem, such as a suitably configured micro-processor based system. Inan embodiment, the technology described herein is implemented in acomputer and/or micro-processor based system.

The various functions of the technology described herein can be carriedout in any desired and suitable manner. For example, the functions ofthe technology described herein can be implemented in hardware orsoftware, as desired. Thus, for example, unless otherwise indicated, thevarious functional elements, stages, and “means” of the technologydescribed herein may comprise a suitable processor or processors,controller or controllers, functional units, circuitry, processinglogic, microprocessor arrangements, etc., that are operable to performthe various functions, etc., such as appropriately dedicated hardwareelements and/or programmable hardware elements that can be programmed tooperate in the desired manner.

In an embodiment, the system comprises, and/or is in communication with,one or more memories and/or memory devices that store the data describedherein, and/or that store software for performing the processesdescribed herein. The system may also be in communication with the hostmicroprocessor, and/or with a display for displaying images based on theoutput of the system.

It should also be noted here that, as will be appreciated by thoseskilled in the art, the various functions, etc., of the technologydescribed herein may be duplicated and/or carried out in parallel on agiven processor. Equally, the various processing stages may shareprocessing circuitry, etc., if desired.

Subject to any hardware necessary to carry out the specific functionsdiscussed above, the data processing system and pipeline can otherwiseinclude any one or more or all of the usual functional units, etc., thatdata processing pipelines include.

It will also be appreciated by those skilled in the art that all of thedescribed embodiments and embodiments of the technology described hereincan, and in some embodiments do, include, as appropriate, any one ormore or all of the optional features described herein.

The methods in accordance with the technology described herein may beimplemented at least partially using software e.g. computer programs. Itwill thus be seen that when viewed from further embodiments thetechnology described herein comprises computer software specificallyadapted to carry out the methods herein described when installed on adata processor, a computer program element comprising computer softwarecode portions for performing the methods herein described when theprogram element is run on a data processor, and a computer programcomprising code adapted to perform all the steps of a method or of themethods herein described when the program is run on a data processingsystem. The data processor may be a microprocessor system, aprogrammable FPGA (field programmable gate array), etc.

The technology described herein also extends to a computer softwarecarrier comprising such software which when used to operate a graphicsprocessor, renderer or microprocessor system comprising a data processorcauses in conjunction with said data processing means said processor,renderer or system to carry out the steps of the methods of thetechnology described herein. Such a computer software carrier could be aphysical storage medium such as a ROM chip, CD ROM, RAM, flash memory,or disk, or could be a signal such as an electronic signal over wires,an optical signal or a radio signal such as to a satellite or the like.

It will further be appreciated that not all steps of the methods of thetechnology described herein need be carried out by computer software andthus from a further broad embodiment the technology described hereincomprises computer software and such software installed on a computersoftware carrier for carrying out at least one of the steps of themethods set out herein.

The technology described herein may accordingly suitably be embodied asa computer program product for use with a computer system. Such animplementation may comprise a series of computer readable instructionseither fixed on a tangible, non-transitory medium, such as a computerreadable medium, for example, diskette, CD-ROM, ROM, RAM, flash memory,or hard disk. It could also comprise a series of computer readableinstructions transmittable to a computer system, via a modem or otherinterface device, over either a tangible medium, including but notlimited to optical or analogue communications lines, or intangibly usingwireless techniques, including but not limited to microwave, infrared orother transmission techniques. The series of computer readableinstructions embodies all or part of the functionality previouslydescribed herein.

Those skilled in the art will appreciate that such computer readableinstructions can be written in a number of programming languages for usewith many computer architectures or operating systems. Further, suchinstructions may be stored using any memory technology, present orfuture, including but not limited to, semiconductor, magnetic, oroptical, or transmitted using any communications technology, present orfuture, including but not limited to optical, infrared, or microwave. Itis contemplated that such a computer program product may be distributedas a removable medium with accompanying printed or electronicdocumentation, for example, shrink-wrapped software, pre-loaded with acomputer system, for example, on a system ROM or fixed disk, ordistributed from a server or electronic bulletin board over a network,for example, the Internet or World Wide Web.

A number of embodiments of the technology described herein will now bedescribed in the context of the processing of computer graphics fordisplay.

FIG. 2 shows a typical computer graphics processing system.

An application 2, such as a game, executing on a host processor 1 willrequire graphics processing operations to be performed by an associatedgraphics processing unit (graphics processing pipeline) 3. To do this,the application will generate API (Application Programming Interface)calls that are interpreted by a driver 4 for the graphics processpipeline 3 that is running on the host processor 1 to generateappropriate commands to the graphics processor 3 to generate graphicsoutput required by the application 2. To facilitate this, a set of“commands” will be provided to the graphics processor 3 in response tocommands from the application 2 running on the host system 1 forgraphics output (e.g. to generate a frame to be displayed).

FIG. 3 shows the graphics processing pipeline 3 of the presentembodiment in more detail.

The graphics processing pipeline 3 shown in FIG. 3 is a tile-basedrenderer and will thus, as is known in the art, produce tiles of arender output data array, such as an output frame to be generated.

(In tile-based rendering, rather than the entire render output, e.g.,frame, effectively being processed in one go as in immediate moderendering, the render output, e.g., frame to be displayed, is dividedinto a plurality of smaller sub-regions, usually referred to as “tiles”.Each tile (sub-region) is rendered separately (typicallyone-after-another), and the rendered tiles (sub-regions) are thenrecombined to provide the complete render output, e.g., frame fordisplay. In such arrangements, the render output is typically dividedinto regularly-sized and shaped sub-regions (tiles) (which are usually,e.g., squares or rectangles), but this is not essential.)

The render output data array may, as is known in the art, typically bean output frame intended for display on a display device, such as ascreen or printer, but may also, for example, comprise intermediate dataintended for use in later rendering passes (also known as a “render totexture” output), etc.

(When a computer graphics image is to be displayed, it is usually firstdefined as a series of primitives (polygons), which primitives are thendivided (rasterised) into graphics fragments for graphics rendering inturn. During a normal graphics rendering operation, the renderer willmodify the (e.g.) colour (red, green and blue, RGB) and transparency(alpha, a) data associated with each fragment so that the fragments canbe displayed correctly. Once the fragments have fully traversed therenderer, then their associated data values are stored in memory, readyfor output, e.g. for display.)

FIG. 3 shows the main elements and pipeline stages of the graphicsprocessing pipeline 3 that are relevant to the operation of the presentembodiment. As will be appreciated by those skilled in the art there maybe other elements of the graphics processing pipeline that are notillustrated in FIG. 3. It should also be noted here that FIG. 3 is onlyschematic, and that, for example, in practice the shown functional unitsand pipeline stages may share significant hardware circuits, even thoughthey are shown schematically as separate stages in FIG. 3. It will alsobe appreciated that each of the stages, elements and units, etc., of thegraphics processing pipeline as shown in FIG. 3 may be implemented asdesired and will accordingly comprise, e.g., appropriate circuitryand/or processing logic, etc., for performing the necessary operationand functions.

As shown in FIG. 3, the graphics processing pipeline 3 includes a numberof stages, including vertex shader 20, a hull shader 21, a tesselator22, a domain shader 23, a geometry shader 24, a rasterisation stage 25,an early Z (depth) and stencil test stage 26, a renderer in the form ofa fragment shading stage 27, a late Z (depth) and stencil test stage 28,a blending stage 29, a tile buffer 30 and a downsampling and writeout(multisample resolve) stage 31.

The vertex shader 20 takes the input data values associated with thevertices, etc., defined for the output to be generated, and processesthose data values to generate a set of corresponding “vertex shaded”output data values for use by subsequent stages of the graphicsprocessing pipeline 3. The vertex shading, for example, modifies theinput data to take account of the effect of lighting in the image to berendered.

The hull shader 21 performs operations on sets of patch control pointsand generates additional data known as patch constants, the tessellationstage 22 subdivides geometry to create higher-order representations ofthe hull, the domain shader 23 performs operations on vertices output bythe tessellation stage (similar to a vertex shader), and the geometryshader 24 processes entire primitives such as a triangles, points orlines. These stages together with the vertex shader 21 effectivelyperform all the necessary fragment frontend operations, such astransformation and lighting operations, and primitive setup, to setupthe primitives to be rendered, in response to commands and vertex dataprovided to the graphics processing pipeline 3.

The rasterisation stage 25 of the graphics processing pipeline 3operates to rasterise the primitives making up the render output (e.g.the image to be displayed) into individual graphics fragments forprocessing. To do this, the rasteriser 25 receives graphics primitivesfor rendering, rasterises the primitives to sampling points andgenerates graphics fragments having appropriate positions (representingappropriate sampling positions) for rendering the primitives.

The fragments generated by the rasteriser are then sent onwards to therest of the pipeline for processing.

The early Z/stencil stage 26 performs a Z (depth) test on fragments itreceives from the rasteriser 25, to see if any fragments can bediscarded (culled) at this stage. To do this, it compares the depthvalues of (associated with) fragments issuing from the rasteriser 25with the depth values of fragments that have already been rendered(these depth values are stored in a depth (Z) buffer that is part of thetile buffer 30) to determine whether the new fragments will be occludedby fragments that have already been rendered (or not). At the same time,an early stencil test is carried out.

Fragments that pass the fragment early Z and stencil test stage 26 arethen sent to the fragment shading stage 27. The fragment shading stage27 performs the appropriate fragment processing operations on thefragments that pass the early Z and stencil tests, so as to process thefragments to generate the appropriate rendered fragment data.

This fragment processing may include any suitable and desired fragmentshading processes, such as executing fragment shader programs on thefragments, applying textures to the fragments, applying fogging or otheroperations to the fragments, etc., to generate the appropriate fragmentdata. In the present embodiment, the fragment shading stage 27 is in theform of a shader pipeline (a programmable fragment shader).

There is then a “late” fragment Z and stencil test stage 28, whichcarries out, inter alia, an end of pipeline depth test on the shadedfragments to determine whether a rendered fragment will actually be seenin the final image. This depth test uses the Z-buffer value for thefragment's position stored in the Z-buffer in the tile buffer 30 todetermine whether the fragment data for the new fragments should replacethe fragment data of the fragments that have already been rendered, by,as is known in the art, comparing the depth values of (associated with)fragments issuing from the fragment shading stage 27 with the depthvalues of fragments that have already been rendered (as stored in thedepth buffer). This late fragment depth and stencil test stage 28 alsocarries out any necessary “late” alpha and/or stencil tests on thefragments.

The fragments that pass the late fragment test stage 28 are thensubjected to, if required, any necessary blending operations withfragments already stored in the tile buffer 30 in the blender 29. Anyother remaining operations necessary on the fragments, such as dither,etc. (not shown) are also carried out at this stage.

Finally, the (blended) output fragment data (values) are written to thetile buffer 30 from where they can, for example, be output to a framebuffer for display. The depth value for an output fragment is alsowritten appropriately to a Z-buffer within the tile buffer 30. (The tilebuffer stores colour and depth buffers that store an appropriate colour,etc., or Z-value, respectively, for each sampling point that the buffersrepresent (in essence for each sampling point of a tile that is beingprocessed).) These buffers store an array of fragment data thatrepresents part (a tile) of the overall render output (e.g. image to bedisplayed), with respective sets of sample values in the bufferscorresponding to respective pixels of the overall render output (e.g.each 2×2 set of sample values may correspond to an output pixel, where4× multisampling is being used).

The tile buffer is provided as part of RAM that is located on (local to)the graphics processing pipeline (chip).

The data from the tile buffer 30 is input to a downsampling (multisampleresolve) write out unit 31, and thence output (written back) to anexternal memory output buffer, such as a frame buffer of a displaydevice (not shown). (The display device could comprise, e.g., a displaycomprising an array of pixels, such as a computer monitor or a printer.)

The downsampling and writeout unit 31 downsamples the fragment datastored in the tile buffer 30 to the appropriate resolution for theoutput buffer (device) (i.e. such that an array of pixel datacorresponding to the pixels of the output device is generated), togenerate output values (pixels) for output to the output buffer.

Once a tile of the render output has been processed and its dataexported to a main memory (e.g. to a frame buffer in a main memory (notshown)) for storage, the next tile is then processed, and so on, untilsufficient tiles have been processed to generate the entire renderoutput (e.g. frame (image) to be displayed). The process is thenrepeated for the next render output (e.g. frame) and so on.

Other arrangements for the graphics processing pipeline 3 would, ofcourse, be possible.

The above describes certain features of the operation of the graphicsprocessing system shown in FIG. 2. Further features of the operation ofthe graphics processing system shown in FIG. 1 in accordance withembodiments of the technology described herein will now be described.

As can be seen from FIG. 3, the graphics processing pipeline 3 includesa number of programmable processing or “shader” stages, namely thevertex shader 20, hull shader 21, domain shader 23, geometry shader 24,and the fragment shader 27. These programmable shader stages executerespective shader programs that have one or more input variables andgenerate sets of output variables and that are provided by theapplication.

To do this, the application 2 provides the shader programs implementedusing a high-level shader programming language, such as GLSL, HLSL,OpenCL, etc. These shader programs are then translated by a shaderlanguage compiler to binary code for the target graphics processingpipeline 3. This may include, as is known in the art, the creation ofone or more intermediate representations of the program within thecompiler. (The compiler may, e.g., be part of the driver 4, with therebeing a special API call to cause the compiler to run. The compilerexecution can thus be seen as being part of the draw call preparationdone by the driver in response to API calls generated by an application.The driver will then issue the compiled program(s) to the graphicsprocessing pipeline 3 for execution by the programmable processingstage(s) of the graphics processing pipeline.)

FIG. 4 illustrates this, and shows the shader program being provided inthe high level shader programming language 40 by the application 2 tothe driver 4, which then compiles 41 the shader program to the binarycode 42 for the graphics processing pipeline 3.

As discussed above, each shader in the graphics processing pipeline is aprocessing unit that performs graphics processing by running smallprograms for each graphics item in a graphics output to be generated (an“item” in this regard is usually a vertex, a fragment or a pixel). Thepresent embodiments relate to the situation where execution threads tobe executed by a shader (where each thread corresponds to one graphicsitem) have been organised into a “group” or “bundle” of threads that areto be run in lockstep, one instruction at a time.

Embodiments of the technology described herein will now be describedwith reference in particular to operations of the fragment shader 27 ofthe graphics processing pipeline.

In the fragment shader 27, the fragment shading program that is beingexecuted is run once for each sampling position (or point) that is to beprocessed, with one execution thread being spawned for each samplingposition. Typically, the sampling positions (and thus accordingly theircorresponding execution threads) are organised into and processed asgroups of plural sampling positions (and thus threads). In the presentembodiments, the sampling positions are organised into 2×2 “quads”, andare correspondingly processed in the fragment shader as thread groupscontaining four threads, each corresponding to one of the samplingpositions of the “quad”. The group of threads representing a givensampling position quad is then run in lockstep, one instruction at atime, through the fragment shader.

FIG. 5 shows a first embodiment of the technology described herein inwhich thread groups being executed by the fragment shader 27 are mergedduring execution of the fragment shader program. This has the effectthat threads that do not need to be executed for parts of the fragmentshader program do not unnecessarily occupy execution lanes and cycles.

As shown in FIG. 5, a (and each) primitive 50 to be rendered israsterised 51 (by testing the primitive 50 against the array of samplingpoints 52 that represents the render output) to generate appropriatefragments 53 corresponding to respective 2×2 sampling position “quads”.

The rasteriser 51 also operates to identify pairs of fragments for theprimitive for which not all the sampling positions in the fragments arecovered by the primitive 50 (and thus for which not all the threads inthe corresponding thread group in the fragment shader will be active).

In the present embodiment, the rasteriser identifies pairs of fragmentshaving non-overlapping covered sampling positions (i.e. that will resultin thread groups having non-overlapping active threads (i.e. for whichthe active threads will reside in different thread group (warp) lanes).(However, it would be possible to identify sets of three or morefragments (thread groups (warps)) that may be merged, if desired.)

The rasteriser could also be configured to be able to re-map theallocation of sampling positions to thread group lanes for thread groups(e.g. by flipping the 2×2 quad that the thread group corresponds tohorizontally or vertically), so as to (try to) remove the overlap forfragments (thread groups) that in their initial configuration haveoverlapping covered sampling positions (active threads) (lanes), toallow such thread groups then to be (potentially) merged, if desired.

The rasteriser then signals to the fragment shader the identifiedfragment pairs (thread groups) that can be merged together, as it issuesthe fragments to the fragment shader, so that the fragment shader canidentify the thread groups that have been identified (associated) as“merge” candidates when they reach the thread group merge event point inthe shader program execution.

(If a fragment to be issued to the fragment shader is identified by therasteriser as being unable to be (potentially) merged with anotherfragment, then the fragment is indicated as being unable to be merged(as to be processed as a single thread group).)

FIG. 5 shows two exemplary “mergeable” fragments 54, 55 corresponding torespective sampling position quads. It can be seen that for both of thefragments (quads) 54, 55, not all of the sampling positions are coveredby the primitive 50 (thus the fragments are “sparse”), and that thecovered sampling positions for the fragments do not overlap.

When the fragments 54, 55 reach the fragment shader 27, correspondingexecution threads are spawned 56 for execution by the fragment shader 27to process the fragments 54, 55. As shown in FIG. 5, in the case of thefragment 54, a thread group 57 comprising three active (“real”) threadsand one inactive, “helper” thread is spawned. Correspondingly, for thefragment 55, a thread group 58 containing three helper threads and oneactive thread is spawned.

The fragment shading stage then executes the fragment shader program forthe thread groups.

First, a first part of the fragment shader program that uses the helperthreads of the thread groups 57, 58 is executed 59. This part of thefragment shader program performs fragment shader program operations thatrequire results for the inactive (helper) threads in the thread groups,such as texture lookups.

There is then a merge instruction 60 in the fragment shader programwhich operates to cause the active threads of the thread groups 57, 58to be merged into a single, combined thread group 61.

To do this, when the first thread group of the pair of thread groups 57,58 that are to be merged reaches the thread group merge instruction inthe shader program execution, shader program execution for that threadgroup is stalled until the other thread group that it is to be mergedwith has also reached the thread group merge instruction in the shaderprogram execution. Then, the thread groups 57, 58 are merged into asingle thread group 61 containing the active threads from each of thethread groups 57, 58.

The thread groups 57, 58 are merged into the single thread group 61containing the active threads from each of the thread groups by mappingthe active threads from each thread group to respective lanes of themerged, single thread group 61. The merged thread groups then proceed asone shared thread group 61, having a single (active) program counter.

Following this thread group merger, the remaining program steps of thefragment shader program are executed 62 for the merged thread group 61.This part of the fragment shader program executes operations, such asarithmetic operations, that do not need to be executed for inactive(helper) threads of the thread group.

(If an “unmergeable” thread group reaches the thread group mergeinstruction in the shader program execution, the thread group mergeevent instruction is ignored (has no effect), and the fragment shaderprogram is simply continued to be executed for the thread group on itsown.)

This is repeated for each fragment that is issued by the rasteriser 51.

FIG. 5 shows the execution of the fragment shader program. In order tofacilitate the operation shown in FIG. 5, the registers that thefragment shader program reads and writes data from and to are arrangedas shown in FIGS. 6A and 6B to facilitate the merging of the threadgroups as shown in FIG. 5. FIG. 6A shows the register arrangement beforethe thread groups are merged, and FIG. 6B shows the register arrangementafter the thread groups are merged.

As shown in FIGS. 6A and 6B, the registers used by the fragment shaderprogram are divided into two subsets, a set 70 of “common” registersthat are physically shared by the thread groups in the pair of threadgroups that are to be merged into the single thread group, andrespective sets 71, 72 of “private” registers that are respectivelyexclusive to each thread group in the pair and inaccessible to the otherthread group in the pair of thread groups that are to be merged.

In the present embodiment, the division of the registers into “common”and “private” subsets is done using a register index cutoff, with allregisters below the cutoff being “common” registers and all registersabove the cutoff being “private” registers. The register index cutoff isspecified by the compiler. Other arrangements for dividing the registersinto “common” and “private” subsets may also or instead be used, ifdesired, such as having a hard coded division of the registers, or abitmap indicating which registers go into which subset.

The common and private registers for the thread groups are used andhandled in the following manner.

Firstly, before the thread group merge instruction 60 in the shaderprogram execution, a thread group can freely both read and write for allthreads (lanes) of the group to and from the private registers for thatthread group (i.e. for both “real” (active) and “helper” (inactive)threads).

Correspondingly, before the thread group merge instruction in the shaderprogram execution, a thread group can only write to the “common”registers for the set of thread groups for its active threads (for lanescontaining “real” (active) threads), and the thread groups can only readthe common registers for their lanes that contain “real” threads (forthe active threads of the thread groups).

After the thread groups have been merged (the merge instruction has beenperformed), the contents of the “private” registers for the threadgroups that were merged are invalidated (and thus only the commonregisters for the thread groups that were merged are considered to havevalid values), and a new set of private registers is allocated for themerged, single thread group (as shown in FIG. 6B). In the presentembodiment the latter is done by mapping the private registers 71 of oneof the thread groups 57 into the register space of the single, mergedthread group 61, but other arrangements would be possible, if desired.

When executing the fragment shader program for the thread groups 57, 58,any operation that requires the use of inactive (“helper”) threads isperformed before the merge event point in the shader program execution,and uses the private registers for the thread group in question.

Correspondingly, any data item from before the merge event point thatneeds to be preserved across the thread group merge event (i.e. thatneeds to be available for the merged, single thread group after themerge event) is stored in the common register(s) (before the mergeevent).

The fragment shader program operations (code) are configured by thecompiler that compiles the fragment shader program code to achieve this.The compiler also includes the merge instruction 60 at the appropriatepoint in the fragment shader program when it compiles the fragmentshader program. FIG. 7 illustrates the operation of the compiler in thisregard.

As shown in FIG. 7, the compiler receives the fragment shader program inthe high level source language 80, and parses 81 and processes 82 thatprogram. It then identifies the program operations that use the inactive(helper) threads 83 and the program operations that only require activethreads 84, and groups those operations appropriately in the compiledfragment shader program (with the program operations that use theinactive (helper) threads being before the program operations that onlyrequire active threads).

The compiler then inserts 85 the thread group merge instruction at theappropriate point in the fragment shader program (i.e. after all theoperations that require the use of inactive (helper threads) in thefragment shader program and before those program operations that onlyrequire active threads).

The so-arranged fragment shader program is then encoded 86 into theappropriate binary code 87 for the graphics processing pipeline and sentto the graphics processing pipeline for execution.

In this embodiment the thread group merge event is provided in thefragment shader program as or as part of an instruction in the fragmentshader program. However, other arrangements would be possible, such asindicating the thread group merge event by means of a modifier of or toan instruction in the fragment shader program, or in some other way,such as a cutoff point specified separately from the fragment shaderprogram code itself.

FIGS. 8 to 10 show a second embodiment of the technology describedherein, in which thread groups are divided (demerged) into pluralseparate thread groups during fragment shader program execution.

This can be useful in graphics processing operations such as samplefrequency shading, in which multiple (e.g. four) sampling points areprocessed for each sampling position within a render output to begenerated, but as well as there being per-sampling point calculationsthat need to be done, there can be some calculations that need to bedone identically for each sampling point for a given sampling position.

FIG. 8 shows schematically the operation in this second embodiment ofthe technology described herein in which thread groups being executed bythe fragment shader 27 are divided (demerged) during execution of thefragment shader program.

As shown in FIG. 8, a (and each) primitive 50 to be rendered is againrasterised 51 (by testing the primitive 50 against the array of samplingpoints 52 that represents the render output) to generate appropriatefragments 53 corresponding to respective 2×2 sampling position “quads”.

However, as shown in FIG. 8, in this case, each sampling position of therender output has two sampling points 90 associated with it (to beprocessed for it by the fragment shader).

The rasteriser identifies those sampling positions of the array 52, andthe respective sampling points for each sampling position, that arecovered by the primitive 50, and generates a fragment for each 2×2sampling position quad that includes a covered sampling point.

FIG. 8 shows an exemplary fragment 91 corresponding to a partiallycovered sampling position quad.

When the fragment 91 reaches the fragment shader 27, correspondingexecution threads are spawned 56 for execution by the fragment shader 27to process the sampling positions that the fragment 91 represents. Asshown in FIG. 8, in the case of the fragment 91, a thread group 92comprising three active (“real”) threads and one inactive, “helper”thread, corresponding to the sampling positions that the fragment 91represents, is spawned.

The fragment shading stage then executes the fragment shader program forthe thread group 92.

First, a first part of the fragment shader program that performsper-sampling position calculations (i.e. calculations that are notdependent upon the position (point) within the render output arearepresented by the sampling position) is executed 93.

There is then a divide instruction 94 in the fragment shader programwhich operates to divide the thread group 92 into two separate threadgroups 95, 96, each representing one set of the sampling points for thesampling positions that the fragment 91 (and thus the thread group 92)represents.

Following this thread group division, the remaining program steps of thefragment shader program are executed 97 for both the thread groups 95,96. This part of the fragment shader program executes operations thatperform per-sampling point calculations (i.e. calculations that aredependent upon the position (point) within the render output arearepresented by the sampling position being considered).

This is repeated for each fragment that is issued by the rasteriser 51.

It should be noted in this regard that although the thread groups 92, 95and 96 shown in FIG. 8 contain both active and inactive threads (inaccordance with which sampling positions and corresponding samplingpoints of the quad are covered by the primitive 50), it can be the case(and indeed may commonly be the case) in this embodiment that eachthread group (i.e. both the initial, single thread group, and the pluralseparate thread groups after the thread group divide event) willcompletely contain active threads (i.e. all the thread group (warp)lanes will be active at all times).

FIG. 8 shows the execution of the fragment shader program in thisembodiment. In order to facilitate the operation shown in FIG. 8, theregisters that the fragment shader program reads and writes data fromand to are arranged as shown in FIGS. 9A and 9B to facilitate thedividing of the thread groups as shown in FIG. 8. FIG. 9A shows theregister arrangement before a thread group is divided, and FIG. 9B showsthe register arrangement after a thread group has been divided.

As shown in FIGS. 9A and 9B, the registers used by the fragment shaderprogram are again divided into two subsets, a set 70 of “common”registers that are physically shared by the thread groups (both beforeand after the thread group is divided), and respective sets 71, 72 of“private” registers that are respectively exclusive to each thread groupand inaccessible to the other thread group in the pair of divided threadgroups. These registers are allocated (reserved) for use by the threadgroups at the start of the shader program execution.

In this embodiment, before the thread group divide point 94 in theshader program execution, the initial “single” thread group 92 uses thecommon registers 70 for the thread groups for its per-sampling positioncalculations (and thus can freely both read and write for all threads(lanes) of the group to and from the common registers for the threadgroups).

Then, after the initial single thread group 92 has been divided (thedivide event 94 has been performed), the common registers 70 for thethread groups are treated as a read-only register(s) (so as to preservethe calculated per-sampling position values), and calculations performedafter the thread group divide event 94 use the private registers 71, 72for the thread group 95, 96 in question.

The fragment shader program operations (code) are again configured bythe compiler that compiles the fragment shader program code to achievethis. The compiler also includes the divide instruction 94 at theappropriate point in the fragment shader program when it compiles thefragment shader program. FIG. 10 illustrates the operation of thecompiler in this regard.

As shown in FIG. 10, the compiler receives the fragment shader programin the high level source language 80, and parses 81 and processes 82that program. It then determines whether a thread group divide event atsome point in the fragment shader program execution is possible, and ifso, then identifies the program operations that are “per-samplingposition” 110 and the program operations that are “per-sampling point”(within a sampling position) 111, and groups those operationsappropriately in the compiled fragment shader program (with the programoperations that are “per-sampling position” 110 being placed before theprogram operations that are “per-sampling point” (within a samplingposition) 111).

The compiler then inserts 112 the thread group divide instruction at theappropriate point in the fragment shader program (i.e. after all theoperations that are “per-sampling position” 110 and before the programoperations that are “per-sampling point” (within a sampling position)111).

The so-arranged fragment shader program is then encoded 86 into theappropriate binary code 87 for the graphics processing pipeline and sentto the graphics processing pipeline for execution.

In this embodiment the thread group divide event is again provided inthe fragment shader program as or as part of an instruction in thefragment shader program. However, other arrangements would again bepossible, such as indicating the thread group divide event by means of amodifier of or to an instruction in the fragment shader program, or insome other way, such as a cutoff point specified separately from thefragment shader program code itself.

It would also be possible to combine the above two embodiments, whereappropriate, i.e. to have a fragment shader program that includes bothmerge and divide points during its execution, where the operations thatthe fragment shader program is to perform facilitate that.

It can be seen from the above that the technology described herein, inits embodiments at least, provides more efficient mechanisms forexecuting shader programs in graphics processing systems. This isachieved, in the embodiments of the technology described herein atleast, by identifying and including opportunities to merge and/or dividethread groups that are executing a shader program to facilitate moreefficient execution of the shader program.

The foregoing detailed description has been presented for the purposesof illustration and description. It is not intended to be exhaustive orto limit the technology to the precise form disclosed. Manymodifications and variations are possible in the light of the aboveteaching. The described embodiments were chosen in order to best explainthe principles of the technology and its practical application, tothereby enable others skilled in the art to best utilise the technologyin various embodiments and with various modifications as are suited tothe particular use contemplated. It is intended that the scope bedefined by the claims appended hereto.

What is claimed is:
 1. A method of operating a graphics processingpipeline which includes a programmable shading stage that executesinstructions to perform shading operations, in which execution threadsmay be grouped together into thread groups in which the threads of thegroup are executed in lockstep, one instruction at a time, the methodcomprising: issuing to the shader stage a shader program for executionby the shader stage to process execution threads for generating a renderoutput, together with a thread group merge event indication thatindicates a point in the shader program execution where thread groupsfor which not all the threads in the thread group are active may bemerged; the graphics processing pipeline: identifying a set of two ormore thread groups to be processed by the shading stage for which notall the threads in the thread groups are active and which may be mergedinto a single thread group; and the shading stage: executing the shaderprogram for the identified thread groups, the executing the shaderprogram for the identified thread groups including: when the identifiedthread groups have reached the thread group merge event indication,merging the thread groups into a single thread group containing theactive threads from each of the thread groups; and executing furtherinstructions in the shader program after the merge event indicationpoint for the merged thread group; the method further comprising:providing for a set of two or more thread groups that are to be mergedinto a single thread group when executing the shader program, for useduring execution of the shader program for the thread groups, a set ofcommon registers that are physically shared by the thread groups in theset of two or more thread groups that are to be merged into the singlethread group, and a set of private registers that are sets of registersthat are respectively exclusive to each thread group in the set of twoor more thread groups that are to be merged and inaccessible to theother thread group or groups in the set of two or more thread groupsthat are to be merged; and storing any data item from before the threadgroup merge event point that needs to be preserved across the threadgroup merge event in the common registers for the set of two or morethread groups.
 2. The method of claim 1, comprising the shader compilerfor the graphics processing pipeline, for a shader program to beexecuted by a shader stage: determining whether there is a point withinthe execution of the shader program where two or more thread groups eachhaving inactive threads may be merged; and when it is determined thatthere is a point in the shader program execution where two or morethread groups having inactive threads may be merged, including in orproviding with the shader program, a thread group merge event indicationthat indicates a point in the shader program execution where two or morethread groups, each having inactive threads, may be merged.
 3. Themethod of claim 2, further comprising: the compiler placing any shaderprogram operations that require results for inactive threads before thethread group merge event point, and placing any shader programoperations that do not need to be executed for inactive threads in athread group after the thread group merge event point, in the shaderprogram execution.
 4. The method of claim 1, wherein thread groups thatwill have non-overlapping active threads are identified as being threadgroups that can be merged into a single thread group.
 5. The method ofclaim 1, further comprising: re-mapping the allocation of samplingpositions to thread group lanes for thread groups, so as to allow threadgroups then to be merged.
 6. The method of claim 1, further comprising:the thread groups, before the thread group merge point in the shaderprogram execution, writing to the common registers for the set of threadgroups only for their respective active threads.
 7. The method of claim6, further comprising: performing any shader program operation thatrequires the use of inactive threads before the merge event point in theshader program execution, and using the private registers for the threadgroup in question.
 8. A method of compiling a program to generateinstructions for a shading stage of a graphics processing pipeline thatexecutes instructions to perform shading operations, and in whichexecution threads may be grouped together into thread groups in whichthe threads of the group are executed in lockstep, one instruction at atime; the method comprising, for a shader program to be executed by ashader stage: determining whether there is a point within the executionof the shader program where two or more thread groups each havinginactive threads may be merged; and when it is determined that there isa point in the shader program execution where two or more thread groupshaving inactive threads may be merged, including in or providing withthe shader program, a thread group merge event indication that indicatesa point in the shader program execution where two or more thread groups,each having inactive threads, may be merged; and further comprising:including in or providing with the shader program an indication, for aset of two or more thread groups that are to be merged into a singlethread group when executing the shader program, of a set of commonregisters that are physically shared by the thread groups in the set oftwo or more thread groups that are to be merged into the single threadgroup, and a set of private registers that are sets of registers thatare respectively exclusive to each thread group in the set of two ormore thread groups and inaccessible to the other thread group or groupsin the set of two or more thread groups that are to be merged, for useduring execution of the shader program for the thread groups; andincluding in the shader program, one or more instructions to cause a setof two or more thread groups that are to be merged into a single threadgroup when executing the shader program, to store any data item frombefore the thread group merge event point that needs to be preservedacross the thread group merge event in the set of common registersindicated for the set of two or more thread groups.
 9. A data processingsystem comprising: a graphics processor that includes programmableshading stage circuitry that executes instructions to perform shadingoperations, and for which execution threads may be grouped together intothread groups in which the threads of the group are executed inlockstep, one instruction at a time, and processing circuitry configuredto compile programs for the shading stage circuitry to generateinstructions for execution by the shading stage circuitry; the compilerprocessing circuitry is configured to: issue to the shader stagecircuitry a shader program for execution by the shader stage circuitryto process execution threads for generating a render output, togetherwith a thread group merge event indication that indicates a point in theshader program execution where thread groups for which not all thethreads in the thread group are active may be merged; the graphicsprocessor further including: processing circuitry configured to identifyrespective sets of two or more thread groups to be processed by theshading stage circuitry for which not all the threads in the threadgroups are active and which may be merged into a respective singlethread group; and for a set of two or more thread groups that are to bemerged into a single thread group when executing a shader program, foruse during execution of the shader program for the thread groups, a setof common registers that are physically shared by the thread groups inthe set of two or more thread groups that are to be merged into thesingle thread group, and a set of private registers that are sets ofregisters that are respectively exclusive to each thread group in theset of two or more thread groups and inaccessible to the other threadgroup or groups in the set of two or more thread groups that are to bemerged; the shading stage circuitry is configured to: execute the shaderprogram for the identified thread groups, the executing the shaderprogram for the identified thread groups including: when thread groupsof a respective identified set of mergeable thread groups have reachedthe thread group merge event indication, merging the thread groups intoa single thread group containing the active threads from each of thethread groups; storing any data item from before the thread group mergeevent point that needs to be preserved across the thread group mergeevent in the common registers for the identified set of mergeable threadgroups; and executing further instructions in the shader program afterthe merge event indication point for the merged thread group.
 10. Thesystem of claim 9, wherein the compiler processing circuitry isconfigured to: determine whether there is a point within the executionof a shader program where two or more thread groups each having inactivethreads may be merged; and when it is determined that there is a pointin a shader program execution where two or more thread groups havinginactive threads may be merged, include in or provide with the shaderprogram, a thread group merge event indication that indicates a point inthe shader program execution where two or more thread groups, eachhaving inactive threads, may be merged.
 11. The system of claim 9,wherein the compiler processing circuitry is configured to: place anyshader program operations that require results for inactive threadsbefore the thread group merge event point, and place any shader programoperations that do not need to be executed for inactive threads in athread group after the thread group merge event point, in the shaderprogram execution.
 12. The system of claim 9, wherein thread groups thatwill have non-overlapping active threads are identified as being threadgroups that can be merged into a single thread group.
 13. The system ofclaim 9, wherein the graphics processor comprises processing circuitryoperable to: re-map the allocation of sampling positions to thread grouplanes for thread groups, so as to allow thread groups then to be merged.14. The system of claim 9, wherein the shading stage circuitry isconfigured to: for the thread groups, before the thread group mergepoint in the shader program execution, write to the common registers forthe set of thread groups only for their respective active threads. 15.The system of claim 9, wherein the shading stage circuitry is configuredto: perform any shader program operation that requires the use ofinactive threads before the merge event point in the shader programexecution, and use the private registers for the thread group inquestion.
 16. A non-transitory computer readable storage medium storingcomputer software code which when executing on at least one processorperforms a method of compiling a program to generate instructions for ashading stage of a graphics processing pipeline that executesinstructions to perform shading operations, and in which executionthreads may be grouped together into thread groups in which the threadsof the group are executed in lockstep, one instruction at a time; themethod comprising, for a shader program to be executed by a shaderstage: determining whether there is a point within the execution of theshader program where two or more thread groups each having inactivethreads may be merged; and when it is determined that there is a pointin the shader program execution where two or more thread groups havinginactive threads may be merged, including in or providing with theshader program, a thread group merge event indication that indicates apoint in the shader program execution where two or more thread groups,each having inactive threads, may be merged; and further comprising:including in or providing with the shader program an indication, for aset of two or more thread groups that are to be merged into a singlethread group when executing the shader program, of a set of commonregisters that are physically shared by the thread groups in the set oftwo or more thread groups that are to be merged into the single threadgroup, and a set of private registers that are sets of registers thatare respectively exclusive to each thread group in the set of two ormore thread groups and inaccessible to the other thread group or groupsin the set of two or more thread groups that are to be merged, for useduring execution of the shader program for the thread groups; andincluding in the shader program, one or more instructions to cause a setof two or more thread groups that are to be merged into a single threadgroup when executing the shader program, to store any data item frombefore the thread group merge event point that needs to be preservedacross the thread group merge event in the set of common registersindicated for the set of two or more thread groups.
 17. A non-transitorycomputer readable storage medium storing computer software code whichwhen executing on at least one processor performs a method of operatinga graphics processing pipeline which includes a programmable shadingstage that executes instructions to perform shading operations, in whichexecution threads may be grouped together into thread groups in whichthe threads of the group are executed in lockstep, one instruction at atime, the method comprising: issuing to the shader stage a shaderprogram for execution by the shader stage to process execution threadsfor generating a render output, together with a thread group merge eventindication that indicates a point in the shader program execution wherethread groups for which not all the threads in the thread group areactive may be merged; the graphics processing pipeline: identifying aset of two or more thread groups to be processed by the shading stagefor which not all the threads in the thread groups are active and whichmay be merged into a single thread group; and the shading stage:executing the shader program for the identified thread groups, theexecuting the shader program for the identified thread groups including:when the identified thread groups have reached the thread group mergeevent indication, merging the thread groups into a single thread groupcontaining the active threads from each of the thread groups; andexecuting further instructions in the shader program after the mergeevent indication point for the merged thread group; the method furthercomprising: providing for a set of two or more thread groups that are tobe merged into a single thread group when executing the shader program,for use during execution of the shader program for the thread groups, aset of common registers that are physically shared by the thread groupsin the set of two or more thread groups that are to be merged into thesingle thread group, and a set of private registers that are sets ofregisters that are respectively exclusive to each thread group in theset of two or more thread groups and inaccessible to the other threadgroup or groups in the set of two or more thread groups that are to bemerged; and storing any data item from before the thread group mergeevent point that needs to be preserved across the thread group mergeevent in the common registers for the set of two or more thread groups.